<template>
    <div>
        <h2>科室显示</h2>

        <a href="/ksadd">去科室添加</a>
        <tr></tr>

        <a href="/ysxs">去医生信息显示</a>
        <tr></tr>

        <a href="/bfxs">去病房显示</a>
        <tr></tr>

          
       
            科室名称 <input type="text" v-model="que.ksmc">
                   最小时间<input type="date" v-model="que.d1">-
                    最大时间<input type="date" v-model="que.d2">

            <input type="button" value="查询" @click="ksxs">
            <input type="button" value="重置" @click="cz">
            <a href="https://localhost:7209/api/Houseksxx/dc">导出科室信息表</a>
           <table class="table">
            <thead>
                <tr>
                    <td>科室名称</td>
                    <td>科室人数</td>
                    <td>科室描述</td>
                    <td>创建日期</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                 <tr v-for="m in data">
                    <td>{{ m.ksmc }}</td>
                    <td>{{ m.ksrs }}</td>
                    <td>{{ m.ksms}}</td>
                    <td>{{ moment(m.kscjrq).format("YYYY-MM-DD") }}</td>
                    <td>
                    <input type="button" value="逻辑删除" @click="xg(m.ksid)">
                    <input type="button" value="修改" @click="xgg(m.ksid)">

                    </td>
                </tr>
            </tbody>
           </table>
      

    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import moment from 'moment';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
const stor= useRouter();


const data=ref([{

  "ksid": 0,
  "ksmc": "",
  "ksrs": "",
  "ksms": "",
  "kssc": true,
  "kscjrq": "2025-05-19T03:31:53.687Z"
}])

const cz=()=>{
   que.value. d1=null,
   que.value. d2=null,
    que.value. ksmc="",
    ksxs()
}

const que=ref({
    d1:null,
    d2:null,
    ksmc:"",
})
onMounted(()=>{
    ksxs();
   
})
const ksxs=()=>{
    axios.get("https://localhost:7209/api/Houseksxx/xs",{params:que.value}).then(res=>{
        data.value=res.data
    })
}
const xg=(a:any)=>{
    if(!confirm("确认删除吗")){
        return
    }
    axios.delete("https://localhost:7209/api/Houseksxx/ksdele",{params:{ksid:a}}).then(res=>{
        if(res.data>0){
            alert("删除成功");
            ksxs();

        }else{
            alert("删除失败")
        }
    })
}
const xgg=(a:any)=>{
    stor.push({path:"/ksxg",query:{ksid:a}})
}

</script>

<style scoped>

</style>